<?php
/*
	区域代理中心
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return['pluginset']=$this->plugin_setting('setting');
if($_RQ['op']=='main'){
	$_SESSION['forward_url']='jy_area_psi/home/';
	$return['setting']=$this->plugin_setting('page');
	model('jy_weishop/member')->checklogin();
	$member=$this->model('member')->check_member();
	$level_id=$member['newlevel_id'];
	$get_levels=$this->model('model')->get_levels(true);
	$member['leveltitle']=$get_levels[$level_id];
	$member['leveltitle']=$member['leveltitle']?:'默认等级';
	$basic=model('core/member')->basic($_SESSION['uid']);
	$member=array_merge($member,$basic);
	$return['member']=$member;
	$data=array();
	//已结算佣金
	$data['balance_total']=$this->sum('balance',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']),'money');
	$data['balance_num']=$this->count('balance',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']));
	//待结算佣金
	$params=array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'status'=>1);
	$data['order_num']=$this->count('commission',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']),'id');
	if($this->setting['balance_day']){
		//结算天数
		$time=TIMESTAMP-intval($this->setting['balance_day'])*86400;
		$params['complete_time <']=$time;
	}
	$data['commission_1']=$this->sum('commission',$params,'money');
	$data['commission_total']=$this->sum('commission',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'type'=>array(2,4,7,8)),'money');
	$data['commission_count']=$this->count('commission',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'type'=>array(2,4,7,8)));
	$return['data']=$data;
	set_html('title','团长中心');
	exi($return);
}

?>